Page({
  data: {
    avatar: "/static/images/avatar_1.jpg",
    nickName: "熊可爱"
  },
  onShow() {
    this.getUserInfo()
  },
  goLogin() {
    wx.navigateTo({
      url: '/pages/login/index',
    })
  },
  async getUserInfo() {
    let res = await wx.http.get('/userInfo')
    console.log(res)
    let { avatar, nickName } = res
    if (!!avatar) {
      this.setData({
        avatar
      })
    }
    if (!!nickName) {
      this.setData({
        nickName
      })
    }
  }
})
